package com.example.service;

import com.example.entity.HotHistory;
import com.example.entity.Kecheng;
import com.example.mapper.HotHistoryMapper;
import com.example.mapper.KechengMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class KechengService {

    @Resource
    private KechengMapper kechengMapper;

    public void add(Kecheng kecheng) {
        kechengMapper.insert(kecheng);
    }

    public void deleteById(Integer id) {
        kechengMapper.deleteById(id);
    }

    public void deleteBatch(List<Integer> ids) {
        for (Integer id : ids){
            this.deleteById(id);
        }
    }

    public void updateById(Kecheng kecheng) {
        kechengMapper.updateById(kecheng);
    }

    public Kecheng selectById(Integer id) {
        return kechengMapper.selectById(id);
    }

    public List<Kecheng> selectAll(Kecheng kecheng) {
        return kechengMapper.selectAll(kecheng);
    }

    public PageInfo<Kecheng> selectPage(Kecheng kecheng, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Kecheng> kechengList = kechengMapper.selectAll(kecheng);
        return PageInfo.of(kechengList);
    }
}
